﻿/*
 * Copyright (C) 2013 David Neal Parsons
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TripleAMapGenerator
{
    class MapGenerator
    {
        public List<string> XmlLines = new List<string>();
        public GameMap Map;

        public MapGenerator()
        {
            Map = new GameMap();
            XmlLines = new List<string>();
        }

        public void CreateLines()
        {
            CreateHeader();
            CreateMapSection();
            CreateResourceSection();
            CreatePlayerList();
            CreateUnitList();
            CreateTerritoryEffectList();
            CreatePlayHeader();
            CreateSequence();
            CreatePlayFooter();
            CreateProduction();
            CreateTechnology();
            CreateAttachments();
            CreateInitializeSection();
            CreatePropertySection();
            CreateFooter();
        }

        private void CreateHeader()
        {
            XmlLines.Add("<?xml version=\"1.0\" ?>");
            XmlLines.Add("<!DOCTYPE game SYSTEM \"game.dtd\">");
            XmlLines.Add("<game>");

            XmlLines.Add("    <info name=\"" + Map.MapName + "\" version=\"" + Form1.Version + "\"/>");
            XmlLines.Add("    <loader javaClass=\"games.strategy.triplea.TripleA\"/>");
            XmlLines.Add("    <triplea minimumVersion=\"1.6\"/>");
            XmlLines.Add("    <diceSides value=\"" + Map.DiceSides + "\"/>");
        }

        private void CreateMapSection()
        {
            XmlLines.Add("    <map>");
            XmlLines.Add("        <!-- Territory Definitions -->");

            foreach (Territory t in Map.Territories)
            {
                if (t.IsWater)
                {
                    XmlLines.Add("        <territory name=\"" + t.Name + "\" water=\"true\"/>");
                }
                else
                {
                    XmlLines.Add("        <territory name=\"" + t.Name + "\"/>");
                }
            }

            XmlLines.Add("");
            XmlLines.Add("        <!-- Territory Connections -->");

            foreach (Connection c in Map.Connections)
            {
                XmlLines.Add("        <connection t1=\"" + c.t1.Name + "\" t2=\"" + c.t2.Name + "\"/>");
            }

            XmlLines.Add("    </map>");
            XmlLines.Add("");
        }

        private void CreateResourceSection()
        {
            XmlLines.Add("    <resourceList>");
            XmlLines.Add("        <resource name=\"PUs\"/>");
            XmlLines.Add("        <resource name=\"techTokens\"/>");
            XmlLines.Add("    </resourceList>");
            XmlLines.Add("");
        }

        private void CreatePlayerList()
        {
            XmlLines.Add("    <playerList>");
            XmlLines.Add("        <!-- In turn order -->");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("        <player name=\"" + p.Name + "\" optional=\"" + p.Optional.ToString().ToLower() + "\"/>");
            }

            XmlLines.Add("");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("        <alliance player=\"" + p.Name + "\" alliance=\"" + p.Alliance + "\"/>");
            }

            XmlLines.Add("    </playerList>");
            XmlLines.Add("");
        }

        private void CreateUnitList()
        {
            XmlLines.Add("");
            XmlLines.Add("    <!-- Unit Definitions -->");
            XmlLines.Add("    <unitList>");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    XmlLines.Add("        <unit name=\"" + u.Name + "\"/>");
                }
            }

            XmlLines.Add("    </unitList>");
            XmlLines.Add("");
        }

        private void CreateTerritoryEffectList()
        {
            XmlLines.Add("    <territoryEffectList>");
            XmlLines.Add("        <territoryEffect name=\"forest\"/>");
            XmlLines.Add("        <territoryEffect name=\"mountain\"/>");
            XmlLines.Add("        <territoryEffect name=\"desert\"/>");
            XmlLines.Add("        <territoryEffect name=\"hills\"/>");
            XmlLines.Add("        <territoryEffect name=\"marsh\"/>");
            XmlLines.Add("        <territoryEffect name=\"city\"/>");
            XmlLines.Add("    </territoryEffectList>");
            XmlLines.Add("");
        }

        private void CreatePlayHeader()
        {
            XmlLines.Add("    <gamePlay>");
            XmlLines.Add("        <delegate name=\"initDelegate\" javaClass=\"games.strategy.triplea.delegate.InitializationDelegate\" display=\"Initializing Delegates\"/>");
            XmlLines.Add("        <delegate name=\"tech\" javaClass=\"games.strategy.triplea.delegate.TechnologyDelegate\" display=\"Research Technology\"/>");
            XmlLines.Add("        <delegate name=\"tech_activation\" javaClass=\"games.strategy.triplea.delegate.TechActivationDelegate\" display=\"Activate Technology\"/>");
            XmlLines.Add("        <delegate name=\"battle\" javaClass=\"games.strategy.triplea.delegate.BattleDelegate\" display=\"Combat\"/>");
            XmlLines.Add("        <delegate name=\"move\" javaClass=\"games.strategy.triplea.delegate.MoveDelegate\" display=\"Combat Move\"/>");
            XmlLines.Add("        <delegate name=\"place\" javaClass=\"games.strategy.triplea.delegate.PlaceDelegate\" display=\"Place Units\"/>");
            XmlLines.Add("        <delegate name=\"purchase\" javaClass=\"games.strategy.triplea.delegate.PurchaseDelegate\" display=\"Purchase Units\"/>");
            XmlLines.Add("        <delegate name=\"endTurn\" javaClass=\"games.strategy.triplea.delegate.EndTurnDelegate\" display=\"Turn Complete\"/>");
            XmlLines.Add("        <delegate name=\"placeBid\" javaClass=\"games.strategy.triplea.delegate.BidPlaceDelegate\" display=\"Bid Placement\"/>");
            XmlLines.Add("        <delegate name=\"bid\" javaClass=\"games.strategy.triplea.delegate.BidPurchaseDelegate\" display=\"Bid Purchase\"/>");
            XmlLines.Add("        <delegate name=\"endRound\" javaClass=\"games.strategy.triplea.delegate.EndRoundDelegate\" display=\"Round Complete\"/>");
        }

        private void CreateSequence()
        {
            XmlLines.Add("        <sequence>");
            XmlLines.Add("            <step name=\"gameInitDelegate\" delegate=\"initDelegate\" maxRunCount=\"1\"/>");
            XmlLines.Add("");
            XmlLines.Add("            <!-- Bid Sequences -->");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("            <step name=\"" + p.Name + "Bid\" delegate=\"bid\" player=\"" + p.Name + "\" maxRunCount=\"1\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "BidPlace\" delegate=\"placeBid\" player=\"" + p.Name + "\" maxRunCount=\"1\"/>");
                XmlLines.Add("");
            }

            XmlLines.Add("            <!-- Player Sequences -->");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("            <step name=\"" + p.Name + "Tech\" delegate=\"tech\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "Purchase\" delegate=\"purchase\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "CombatMove\" delegate=\"move\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "Battle\" delegate=\"battle\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "NonCombatMove\" delegate=\"move\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "Place\" delegate=\"place\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "TechActivation\" delegate=\"tech_activation\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("            <step name=\"" + p.Name + "EndTurn\" delegate=\"endTurn\" player=\"" + p.Name + "\"/>");
                XmlLines.Add("");
            }

            XmlLines.Add("            <step name=\"endRoundStep\" delegate=\"endRound\"/>");
            XmlLines.Add("        </sequence>");
        }

        private void CreatePlayFooter()
        {
            XmlLines.Add("    </gamePlay>");
        }

        private void CreateProduction()
        {
            XmlLines.Add("    <production>");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    string buyName = u.Name.Substring(0, 1).ToUpper() + u.Name.Substring(1, u.Name.Length - 1);
                    buyName = buyName.Replace("AaGun", "AAGun");
                    XmlLines.Add("        <productionRule name=\"buy" + buyName + "\">");
                    XmlLines.Add("            <cost resource=\"" + u.cost.ResourceType + "\" quantity=\"" + u.cost.cost + "\"/>");
                    XmlLines.Add("            <result resourceOrUnit=\"" + u.cost.result.ResourceOrUnitName + "\" quantity=\"" + u.cost.result.BuyQuantity + "\"/>");
                    XmlLines.Add("        </productionRule>");
                }
            }

            XmlLines.Add("");
            XmlLines.Add("        <!-- Advanced Industrial Production -->");
            XmlLines.Add("");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    string buyName = u.Name.Substring(0, 1).ToUpper() + u.Name.Substring(1, u.Name.Length - 1);
                    buyName = buyName.Replace("AaGun", "AAGun");
                    XmlLines.Add("        <productionRule name=\"buy" + buyName + "IndustrialTechnology\">");
                    XmlLines.Add("            <cost resource=\"" + u.techCost.ResourceType + "\" quantity=\"" + u.techCost.cost + "\"/>");
                    XmlLines.Add("            <result resourceOrUnit=\"" + u.techCost.result.ResourceOrUnitName + "\" quantity=\"" + u.techCost.result.BuyQuantity + "\"/>");
                    XmlLines.Add("        </productionRule>");
                }
            }

            XmlLines.Add("        <productionFrontier name=\"production\">");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    string buyName = u.Name.Substring(0, 1).ToUpper() + u.Name.Substring(1, u.Name.Length - 1);
                    buyName = buyName.Replace("AaGun", "AAGun");
                    XmlLines.Add("            <frontierRules name=\"buy" + buyName + "\"/>");
                }
            }

            XmlLines.Add("        </productionFrontier>");

            XmlLines.Add("        <productionFrontier name=\"productionIndustrialTechnology\">");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    string buyName = u.Name.Substring(0, 1).ToUpper() + u.Name.Substring(1, u.Name.Length - 1);
                    buyName = buyName.Replace("AaGun", "AAGun");
                    XmlLines.Add("            <frontierRules name=\"buy" + buyName + "IndustrialTechnology\"/>");
                }
            }

            XmlLines.Add("        </productionFrontier>");


            foreach (Player p in Map.Players)
            {
                XmlLines.Add("        <playerProduction player=\"" + p.Name + "\" frontier=\"production\"/>");
            }

            XmlLines.Add("    </production>");
            XmlLines.Add("");
        }

        private void CreateTechnology()
        {
            XmlLines.Add("    <technology>");
            XmlLines.Add("        <technologies>");
            XmlLines.Add("            <techname name=\"superSub\"/>");
            XmlLines.Add("            <techname name=\"jetPower\"/>");
            XmlLines.Add("            <techname name=\"aARadar\"/>");
            XmlLines.Add("            <techname name=\"longRangeAir\"/>");
            XmlLines.Add("            <techname name=\"heavyBomber\"/>");
            XmlLines.Add("            <techname name=\"improvedArtillerySupport\"/>");
            XmlLines.Add("            <techname name=\"rocket\"/>");
            XmlLines.Add("            <techname name=\"paratroopers\"/>");
            XmlLines.Add("            <techname name=\"increasedFactoryProduction\"/>");
            XmlLines.Add("            <techname name=\"warBonds\"/>");
            XmlLines.Add("            <techname name=\"mechanizedInfantry\"/>");
            XmlLines.Add("            <techname name=\"destroyerBombard\"/>");
            XmlLines.Add("            <techname name=\"industrialTechnology\"/>");
            XmlLines.Add("        </technologies>");
            XmlLines.Add("");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("        <playerTech player=\"" + p.Name + "\">");
                XmlLines.Add("            <category name=\"Air Advances\">");
                XmlLines.Add("                <tech name=\"jetPower\"/>");
                XmlLines.Add("                <tech name=\"aARadar\"/>");
                XmlLines.Add("                <tech name=\"longRangeAir\"/>");
                XmlLines.Add("                <tech name=\"heavyBomber\"/>");
                XmlLines.Add("            </category>");
                XmlLines.Add("            <category name=\"Naval Advances\">");
                XmlLines.Add("                <tech name=\"superSub\"/>");
                XmlLines.Add("                <tech name=\"destroyerBombard\"/>");
                XmlLines.Add("            </category>");
                XmlLines.Add("            <category name=\"Land Unit Advances\">");
                XmlLines.Add("                <tech name=\"improvedArtillerySupport\"/>");
                XmlLines.Add("                <tech name=\"paratroopers\"/>");
                XmlLines.Add("                <tech name=\"mechanizedInfantry\"/>");
                XmlLines.Add("            </category>");
                XmlLines.Add("            <category name=\"Production Advances\">");
                XmlLines.Add("                <tech name=\"increasedFactoryProduction\"/>");
                XmlLines.Add("                <tech name=\"warBonds\"/>");
                XmlLines.Add("                <tech name=\"industrialTechnology\"/>");
                XmlLines.Add("            </category>");
                XmlLines.Add("        </playerTech>");
            }

            XmlLines.Add("    </technology>");
            XmlLines.Add("");
        }

        private void CreateAttachments()
        {
            XmlLines.Add("    <attatchmentList>");
            XmlLines.Add("");
            XmlLines.Add("        <!-- Tech Attachments -->");

            string initialJet = Map.InitialJet ? "True" : "False";
            string initialSub = Map.InitialSub ? "True" : "False";
            string initialAir = Map.InitialAir ? "True" : "False";
            string initialDestroyer = Map.InitialDestroyer ? "True" : "False";
            string initialBomber = Map.InitialBomber ? "True" : "False";
            string initialIT = Map.InitialIT ? "True" : "False";

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("        <attatchment name=\"techAttatchment\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.TechAttachment\" type=\"player\">");
                XmlLines.Add("            <option name=\"techCost\" value=\"5\"/>");
                XmlLines.Add("            <option name=\"superSub\" value=\"" + initialSub + "\"/>");
                XmlLines.Add("            <option name=\"destroyerBombard\" value=\"" + initialDestroyer + "\"/>");
                XmlLines.Add("            <option name=\"jetPower\" value=\"" + initialJet + "\"/>");
                XmlLines.Add("            <option name=\"aARadar\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"longRangeAir\" value=\"" + initialAir + "\"/>");
                XmlLines.Add("            <option name=\"heavyBomber\" value=\"" + initialBomber + "\"/>");
                XmlLines.Add("            <option name=\"rocket\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"improvedArtillerySupport\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"paratroopers\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"mechanizedInfantry\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"increasedFactoryProduction\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"warBonds\" value=\"False\"/>");
                XmlLines.Add("            <option name=\"industrialTechnology\" value=\"" + initialIT + "\"/>");
                XmlLines.Add("        </attatchment>");
            }

            XmlLines.Add("");
            XmlLines.Add("        <!-- Unit Attachments -->");

            foreach (Unit u in Map.Units)
            {
                if ((!u.IsAdditional && !Map.UseAdditional) || Map.UseAdditional)
                {
                    XmlLines.Add("        <attatchment name=\"unitAttatchment\" attatchTo=\"" + u.Name + "\" javaClass=\"games.strategy.triplea.attatchments.UnitAttachment\" type=\"unitType\">");

                    foreach (UnitOption uo in u.attachment.options)
                    {
                        XmlLines.Add("            <option name=\"" + uo.Name + "\" value=\"" + uo.Value + "\"/>");
                    }

                    XmlLines.Add("        </attatchment>");
                }
            }

            XmlLines.Add("");
            XmlLines.Add("        <!-- Territory Attachments -->");

            foreach (Territory t in Map.Territories)
            {
                XmlLines.Add("        <attatchment name=\"territoryAttatchment\" attatchTo=\"" + t.Name + "\" javaClass=\"games.strategy.triplea.attatchments.TerritoryAttachment\" type=\"territory\">");
                XmlLines.Add("            <option name=\"production\" value=\"" + t.Production + "\"/>");

                if (t.IsCapitol)
                {
                    XmlLines.Add("            <option name=\"capital\" value=\"" + t.Owner.Name + "\"/>");
                }

                if (t.IsImpassable)
                {
                    XmlLines.Add("            <option name=\"isImpassible\" value=\"true\"/>");
                }

                if (t.IsVictoryCity)
                {
                    XmlLines.Add("            <option name=\"victoryCity\" value=\"true\"/>");
                }

                if (!String.IsNullOrEmpty(t.TerritoryEffect))
                {
                    XmlLines.Add("            <option name=\"territoryEffect\" value=\"" + t.TerritoryEffect + "\"/>");
                }

                XmlLines.Add("        </attatchment>");
            }

            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"forest\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"fighter\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"combatDefenseEffect\" value=\"armour\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"noBlitz\" value=\"scout:halftrack:armour\"/>");
            XmlLines.Add("        </attatchment>");
            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"mountain\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"armour\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"elite\" count=\"+1\"/>");
            XmlLines.Add("            <option name=\"noBlitz\" value=\"scout:halftrack:armour\"/>");
            XmlLines.Add("        </attatchment>");
            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"desert\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"infantry\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"artillery\" count=\"+1\"/>");
            XmlLines.Add("            <option name=\"noBlitz\" value=\"scout:halftrack:armour\"/>");
            XmlLines.Add("        </attatchment>");
            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"hills\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"infantry\" count=\"+1\"/>");
            XmlLines.Add("            <option name=\"combatDefenseEffect\" value=\"halftrack\" count=\"-1\"/>");
            XmlLines.Add("        </attatchment>");
            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"marsh\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"armour:halftrack\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"combatDefenseEffect\" value=\"armour:halftrack\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"noBlitz\" value=\"scout:halftrack:armour\"/>");
            XmlLines.Add("        </attatchment>");
            XmlLines.Add("        <attatchment name=\"territoryEffectAttachment\" attatchTo=\"city\" javaClass=\"games.strategy.triplea.attatchments.TerritoryEffectAttachment\" type=\"territoryEffect\">");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"fighter\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"combatOffenseEffect\" value=\"infantry:elite\" count=\"+1\"/>");
            XmlLines.Add("            <option name=\"combatDefenseEffect\" value=\"armour:halftrack\" count=\"-1\"/>");
            XmlLines.Add("            <option name=\"noBlitz\" value=\"scout:halftrack:armour\"/>");
            XmlLines.Add("        </attatchment>");

            XmlLines.Add("");
            XmlLines.Add("        <!-- Victory Conditions -->");

            if (Map.CTF)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"conditionAttachment" + p.Name + "_CTF\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.RulesAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"alliedOwnershipTerritories\" value=\"" + Map.FlagLocation + "\" count=\"1\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            if (Map.OwnCapitals)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"conditionAttachment" + p.Name + "_Capitals\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.RulesAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"alliedOwnershipTerritories\" value=\"" + Map.CapitalLocations + "\" count=\"" + Map.NumberOfPlayers + "\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            if (Map.OwnPercentVC)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"conditionAttachment" + p.Name + "_VC\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.RulesAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"alliedOwnershipTerritories\" value=\"" + Map.VCLocations + "\" count=\"" + Map.NumberOfVCToWin + "\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            XmlLines.Add("");
            XmlLines.Add("        <!-- Victory Triggers -->");

            if (Map.CTF)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"triggerAttachment" + p.Name + "Win_CTF\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.TriggerAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"trigger\" value=\"conditionAttachment" + p.Name + "_CTF\"/>");
                    XmlLines.Add("            <option name=\"when\" value=\"before:" + p.Name + "Purchase\"/>");
                    XmlLines.Add("            <option name=\"victory\" value=\"TriggeredWin\"/>");
                    XmlLines.Add("            <option name=\"players\" value=\"" + p.Name + "\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            if (Map.OwnCapitals)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"triggerAttachment" + p.Name + "Win_Capitals\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.TriggerAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"trigger\" value=\"conditionAttachment" + p.Name + "_Capitals\"/>");
                    XmlLines.Add("            <option name=\"when\" value=\"before:" + p.Name + "Purchase\"/>");
                    XmlLines.Add("            <option name=\"victory\" value=\"TriggeredWin\"/>");
                    XmlLines.Add("            <option name=\"players\" value=\"" + p.Name + "\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            if (Map.OwnPercentVC)
            {
                foreach (Player p in Map.Players)
                {
                    XmlLines.Add("        <attatchment name=\"triggerAttachment" + p.Name + "Win_VC\" attatchTo=\"" + p.Name + "\" javaClass=\"games.strategy.triplea.attatchments.TriggerAttachment\" type=\"player\">");
                    XmlLines.Add("            <option name=\"trigger\" value=\"conditionAttachment" + p.Name + "_VC\"/>");
                    XmlLines.Add("            <option name=\"when\" value=\"before:" + p.Name + "Purchase\"/>");
                    XmlLines.Add("            <option name=\"victory\" value=\"TriggeredWin\"/>");
                    XmlLines.Add("            <option name=\"players\" value=\"" + p.Name + "\"/>");
                    XmlLines.Add("        </attatchment>");
                }
            }

            XmlLines.Add("    </attatchmentList>");
        }

        private void CreateInitializeSection()
        {
            XmlLines.Add("");
            XmlLines.Add("    <initialize>");

            XmlLines.Add("        <ownerInitialize>");
            foreach (Territory t in Map.Territories)
            {
                if (!String.IsNullOrEmpty(t.Owner.Name))
                {
                    XmlLines.Add("            <territoryOwner territory=\"" + t.Name + "\" owner=\"" + t.Owner.Name + "\"/>");
                }
            }
            XmlLines.Add("        </ownerInitialize>");

            XmlLines.Add("        <unitInitialize>");
            foreach (Territory t in Map.Territories)
            {
                if (!String.IsNullOrEmpty(t.Owner.Name))
                {
                    for (int i = 0; i < t.Units.Count; i++)
                    {
                        XmlLines.Add("            <unitPlacement unitType=\"" + t.Units[i].Name + "\" territory=\"" + t.Name + "\" quantity=\"" +t.placeQty[i] + "\" owner=\"" + t.Owner.Name + "\"/>");
                    }
                }
                else
                {
                    for (int i = 0; i < t.Units.Count; i++)
                    {
                        XmlLines.Add("            <unitPlacement unitType=\"" + t.Units[i].Name + "\" territory=\"" + t.Name + "\" quantity=\"" + t.placeQty[i] + "\"/>");
                    }
                }
            }
            XmlLines.Add("        </unitInitialize>");

            XmlLines.Add("        <resourceInitialize>");
            foreach (Player p in Map.Players)
            {
                XmlLines.Add("            <resourceGiven player=\"" + p.Name + "\" resource=\"PUs\" quantity=\"" + p.InitialResources + "\"/>");
            }
            XmlLines.Add("        </resourceInitialize>");

            XmlLines.Add("    </initialize>");
        }

        private void CreatePropertySection()
        {
            XmlLines.Add("    <propertyList>");

            foreach (Player p in Map.Players)
            {
                XmlLines.Add("            <property name=\"" + p.Name + " bid\" value=\"" + Map.Bid + "\" editable=\"true\">");
                XmlLines.Add("                <number min=\"0\" max=\"1000\"/>");
                XmlLines.Add("            </property>");
            }

            if (Map.UseTriggers)
            {
                XmlLines.Add("            <property name=\"Triggered Victory\" value=\"true\" editable=\"true\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }

            XmlLines.Add("            <property name=\"Low Luck\" value=\"true\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            if (Map.UseTriggers)
            {
                XmlLines.Add("            <property name=\"Use Triggers\" value=\"true\" editable=\"true\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }

            if (Map.UseTech)
            {
                XmlLines.Add("            <property name=\"Tech Development\" value=\"true\" editable=\"true\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }
            else
            {
                XmlLines.Add("            <property name=\"Tech Development\" value=\"false\" editable=\"true\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }

            XmlLines.Add("            <property name=\"LHTR Heavy Bombers\" value=\"true\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Heavy Bomber Dice Rolls\" value=\"2\" editable=\"true\">");
            XmlLines.Add("                <number min=\"2\" max=\"10\"/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Always on AA\" value=\"true\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Kamikaze Airplanes\" value=\"false\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Battleships repair at end of round\" value=\"true\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            if (Map.WW2V2)
            {
                XmlLines.Add("            <property name=\"WW2V2\" value=\"true\" editable=\"false\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }
            else
            {
                XmlLines.Add("            <property name=\"WW2V3\" value=\"true\" editable=\"false\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
                XmlLines.Add("            <property name=\"WW2V3 Tech Model\" value=\"true\" editable=\"false\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
                XmlLines.Add("            <property name=\"Selectable Tech Roll\" value=\"false\" editable=\"false\">");
                XmlLines.Add("                <boolean/>");
                XmlLines.Add("            </property>");
            }

            XmlLines.Add("            <property name=\"Roll AA Individually\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Choose AA Casualties\" value=\"false\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Allied Air Dependents\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Submersible Subs\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Sub Control Sea Zone Restricted\" value=\"false\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Two hit battleship\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Produce fighters on carriers\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Move existing fighters to new carriers\" value=\"true\" editable=\"false\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"Territory Turn Limit\" value=\"false\" editable=\"true\">");
            XmlLines.Add("                <boolean/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"maxFactoriesPerTerritory\" value=\"1\" editable=\"false\">");
            XmlLines.Add("                <number min=\"1\" max=\"10\"/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"mapName\" value=\"Random_Campaign\" editable=\"false\">");
            XmlLines.Add("                <string/>");
            XmlLines.Add("            </property>");

            XmlLines.Add("            <property name=\"notes\">");
            XmlLines.Add("                <value>");
            XmlLines.Add("                <![CDATA[");
            XmlLines.Add("<br>============================================");
            XmlLines.Add("<br><H1>Random Campaign</H1>");
            XmlLines.Add("<br><H1>Map Name: " + Map.MapName + "</H1>");
            XmlLines.Add("<br>Generated by TripleA Map Generator");
            string nextLine = "<br>Version " + Form1.Version + (Form1.Beta ? " Beta" : "");
            XmlLines.Add(nextLine);
            XmlLines.Add("<br>");

            nextLine = "<table border=\"1\">";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Size" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.NumberOfColumns + " X " + Map.NumberOfRows + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Random Seed" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.RandomSeed.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Dice Sides" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.DiceSides.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Players" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.NumberOfPlayers.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Teams" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + (Map.FFA ? "None" : Map.NumberOfTeams.ToString()) + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Water" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentWater.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Impassable" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentImpassable.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Forest" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentForest.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Mountain" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentMtn.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Desert" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentDesert.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Hill" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentHill.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Marsh" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentMarsh.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "City" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentCity.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Capital Size" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.CapitalSize.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Capital Distance" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.CapitalDistance.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Initial Resources" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.ResourcesGiven.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Resource Boost" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.BoostPerPlayer.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Default Bid" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.Bid.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Neutral Extras" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentNeutralExtras.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Victory Cities" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentVC.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Additional Units" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.UseAdditional.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Default Tech" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.UseTech.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Percent IT" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.PercentTech.ToString() + "%</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Own Capitals" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.OwnCapitals.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Own Percent VC" + "</td>";
            XmlLines.Add(nextLine);

            if (Map.OwnPercentVC)
            {
                nextLine = "<td>" + Map.OwnPercentVCAmount.ToString() + "%</td>";
            }
            else
            {
                nextLine = "<td>" + Map.OwnPercentVC.ToString() + "</td>";
            }

            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Capture the Flag" + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + Map.CTF.ToString() + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<td>" + "Rule Set" + "</td>";
            XmlLines.Add(nextLine);
            string rule = Map.WW2V2 ? "WW2V2" : "WW2V3";
            nextLine = "<td>" + rule + "</td>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);
            nextLine = "</table>";
            XmlLines.Add(nextLine);

            XmlLines.Add("<br>============================================");
            XmlLines.Add("<br>");
            XmlLines.Add("<br>Bunkers: ");
            XmlLines.Add("<br>-Use Edit To Place");
            XmlLines.Add("<br>");
            XmlLines.Add("<br>============================================");
            XmlLines.Add("<br>");
            XmlLines.Add("<br>Units:");
            XmlLines.Add("<br>");

            nextLine = "<table border=\"1\">";
            XmlLines.Add(nextLine);
            nextLine = "<tr>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Name</th>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Atk</th>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Def</th>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Mov</th>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Cost</th>";
            XmlLines.Add(nextLine);
            nextLine = "<th>Ability</th>";
            XmlLines.Add(nextLine);
            nextLine = "</tr>";
            XmlLines.Add(nextLine);

            foreach (Unit u in Map.Units)
            {
                if (!u.IsAdditional)
                {
                    nextLine = "<tr>";
                    XmlLines.Add(nextLine);
                    nextLine = "<td>" + u.Name + "</td>";
                    XmlLines.Add(nextLine);

                    string attackValue = "";
                    string defenseValue = "";
                    string movementValue = "";
                    string abilityValue = "";
                    foreach (UnitOption uo in u.attachment.options)
                    {
                        switch (uo.Name)
                        {
                            case "attack":
                                attackValue = uo.Value.ToString();
                                break;
                            case "defense":
                                defenseValue = uo.Value.ToString();
                                break;
                            case "movement":
                                movementValue = uo.Value.ToString();
                                break;
                            case "isAir":
                                abilityValue += "Air ";
                                break;
                            case "isSea":
                                abilityValue += "Sea ";
                                break;
                            case "isTwoHit":
                                abilityValue += "TwoHit ";
                                break;
                            default:
                                break;
                        }
                    }
                    nextLine = "<td>" + attackValue + "</td>";
                    XmlLines.Add(nextLine);
                    nextLine = "<td>" + defenseValue + "</td>";
                    XmlLines.Add(nextLine);
                    nextLine = "<td>" + movementValue + "</td>";
                    XmlLines.Add(nextLine);
                    nextLine = "<td>" + u.cost.cost + "</td>";
                    XmlLines.Add(nextLine);
                    nextLine = "<td>" + abilityValue + "</td>";
                    XmlLines.Add(nextLine);
                    nextLine = "</tr>";
                    XmlLines.Add(nextLine);
                }
            }

            nextLine = "</table>";
            XmlLines.Add(nextLine);

            if (Map.UseAdditional)
            {
                XmlLines.Add("<br>");
                XmlLines.Add("<br>Additional Units:");
                XmlLines.Add("<br>");

                nextLine = "<table border=\"1\">";
                XmlLines.Add(nextLine);
                nextLine = "<tr>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Name</th>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Atk</th>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Def</th>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Mov</th>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Cost</th>";
                XmlLines.Add(nextLine);
                nextLine = "<th>Ability</th>";
                XmlLines.Add(nextLine);
                nextLine = "</tr>";
                XmlLines.Add(nextLine);

                foreach (Unit u in Map.Units)
                {
                    if (u.IsAdditional)
                    {
                        nextLine = "<tr>";
                        XmlLines.Add(nextLine);
                        nextLine = "<td>" + u.Name + "</td>";
                        XmlLines.Add(nextLine);

                        string attackValue = "";
                        string defenseValue = "";
                        string movementValue = "";
                        string abilityValue = "";
                        foreach (UnitOption uo in u.attachment.options)
                        {
                            switch (uo.Name)
                            {
                                case "attack":
                                    attackValue = uo.Value.ToString();
                                    break;
                                case "defense":
                                    defenseValue = uo.Value.ToString();
                                    break;
                                case "movement":
                                    movementValue = uo.Value.ToString();
                                    break;
                                case "isAir":
                                    abilityValue += "Air ";
                                    break;
                                case "isSea":
                                    abilityValue += "Sea ";
                                    break;
                                case "isTwoHit":
                                    abilityValue += "TwoHit ";
                                    break;
                                default:
                                    break;
                            }
                        }
                        nextLine = "<td>" + attackValue + "</td>";
                        XmlLines.Add(nextLine);
                        nextLine = "<td>" + defenseValue + "</td>";
                        XmlLines.Add(nextLine);
                        nextLine = "<td>" + movementValue + "</td>";
                        XmlLines.Add(nextLine);
                        nextLine = "<td>" + u.cost.cost + "</td>";
                        XmlLines.Add(nextLine);
                        nextLine = "<td>" + abilityValue + "</td>";
                        XmlLines.Add(nextLine);
                        nextLine = "</tr>";
                        XmlLines.Add(nextLine);
                    }
                }

                nextLine = "</table>";
                XmlLines.Add(nextLine);
                XmlLines.Add("<br>");
            }

            XmlLines.Add("<br>Turn Order:");
            XmlLines.Add("<br>  ");

            foreach (Player p in Map.Players)
            {
                nextLine = "<br>" + p.Name;
                if (!Map.FFA)
                {
                    nextLine = nextLine + " - " + p.Alliance;
                }
                XmlLines.Add(nextLine);
            }

            XmlLines.Add("<br>");
            XmlLines.Add("<br>DNP");
            XmlLines.Add("<br>");
            XmlLines.Add("<br>");
            XmlLines.Add("");
            XmlLines.Add("]]>");
            XmlLines.Add("            </value>");
            XmlLines.Add("        </property>");
            XmlLines.Add("    </propertyList>");
        }

        private void CreateFooter()
        {
            XmlLines.Add("</game>");
        }
    }
}
